<?php 


function login($login)
{
	if(!isset($_SESSION['accounts']))
	{
		echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
		echo "<script type='text/javascript'>alert('$login');location.href='login.html'</script>";
	}
	if($_SESSION['agencylv']!=100)
	{
		echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
		echo "<script type='text/javascript'>alert('您好，您的权限不足');location.href='http://".$_SERVER['SERVER_NAME']."/agent_admin/login.html'</script>";
	}	
}
function times()
{
		$sdate=$_POST['sdate'];																		//POST来的时间转为时间戳
		$edate=$_POST['edate'];																		//POST来的时间转为时间戳
		$arr['times']=array('between',array($sdate,$edate));															//判断大于等于起始时间的条件
}

function gura($error)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$error');location.href='grabble.html'</script>";die;
}


function deduct($error)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$error');location.href='deduct.html'</script>";die;
}
function change($error)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$error');location.href='supervise.html'</script>";die;
}

function error($error)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$error');history.go(-1)</script>";die;
}

function prompt($error)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$error');location.href='prompt.html'</script>";die;
}

function login_error($login)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('$login');location.href='login.html'</script>";
}

function gems($gems)
{
	echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	echo "<script type='text/javascript'>alert('当前用户需积累".$gems."可获得返利，请先清空后，再更改返利条件条件');history.go(-1)</script>";die;
}

function get_str($model,$state = false,$sql) {
	$func = function (&$cate, $a = 0) use ($model, $state, $sql, &$func) {
		if($state == false){
		    $sql = "select * from t_agent where referrer=".$a;
		} else {
			$value = array();
			$value[] = $a;
			$sql = format($sql, $value);
		}

		//dump($sql);die;
		$result = $model->query($sql);
		if(count($result) > 0){
			for ($i = 0; $i < count($result); $i++) {
				array_push($cate, $result[$i]);
				$func($cate, $result[$i]['accounts']);
			}
		}
	};
	return $func;
}


?>